<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noodp" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
        <title>Redis安装及远程连接相关的问题(Linux--docker) - 断点的博客</title><meta name="Description" content="Redis安装及远程连接相关的问题(Linux--docker)"><meta property="og:title" content="Redis安装及远程连接相关的问题(Linux--docker)" />
<meta property="og:description" content="Redis安装及远程连接相关的问题(Linux--docker)" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://breakpoint2333.gitee.io/breakpoint/posts/redis%E5%AE%89%E8%A3%85%E5%8F%8A%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5%E7%9B%B8%E5%85%B3%E7%9A%84%E9%97%AE%E9%A2%98/" /><meta property="article:section" content="posts" />
<meta property="article:published_time" content="2020-07-04T17:55:28&#43;08:00" />
<meta property="article:modified_time" content="2020-07-04T17:55:28&#43;08:00" />

<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Redis安装及远程连接相关的问题(Linux--docker)"/>
<meta name="twitter:description" content="Redis安装及远程连接相关的问题(Linux--docker)"/>
<meta name="application-name" content="断点的博客">
<meta name="apple-mobile-web-app-title" content="断点的博客"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
        <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="manifest" href="/site.webmanifest"><link rel="canonical" href="https://breakpoint2333.gitee.io/breakpoint/posts/redis%E5%AE%89%E8%A3%85%E5%8F%8A%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5%E7%9B%B8%E5%85%B3%E7%9A%84%E9%97%AE%E9%A2%98/" /><link rel="prev" href="https://breakpoint2333.gitee.io/breakpoint/posts/emoji-support/" /><link rel="next" href="https://breakpoint2333.gitee.io/breakpoint/posts/mysql-docker%E5%AE%89%E8%A3%85/" /><link rel="stylesheet" href="/breakpoint/lib/normalize/normalize.min.css"><link rel="stylesheet" href="/breakpoint/css/style.min.css"><link rel="stylesheet" href="/breakpoint/lib/fontawesome-free/all.min.css"><link rel="stylesheet" href="/breakpoint/lib/animate/animate.min.css"><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "Redis安装及远程连接相关的问题(Linux--docker)",
        "inLanguage": "zh-CN",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "https:\/\/breakpoint2333.gitee.io\/breakpoint\/posts\/redis%E5%AE%89%E8%A3%85%E5%8F%8A%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5%E7%9B%B8%E5%85%B3%E7%9A%84%E9%97%AE%E9%A2%98\/"
        },"genre": "posts","keywords": "项目搭建, docker, linux","wordcount":  751 ,
        "url": "https:\/\/breakpoint2333.gitee.io\/breakpoint\/posts\/redis%E5%AE%89%E8%A3%85%E5%8F%8A%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5%E7%9B%B8%E5%85%B3%E7%9A%84%E9%97%AE%E9%A2%98\/","datePublished": "2020-07-04T17:55:28+08:00","dateModified": "2020-07-04T17:55:28+08:00","publisher": {
            "@type": "Organization",
            "name": "BreakPoint2333"},"author": {
                "@type": "Person",
                "name": "BreakPoint2333"
            },"description": "Redis安装及远程连接相关的问题(Linux--docker)"
    }
    </script></head>
    <body header-desktop="" header-mobile=""><script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>

        <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="/breakpoint/" title="断点的博客"><span class="header-title-pre"><i class='far fa-kiss-wink-heart fa-fw'></i></span><span id="id-1" class="typeit"></span></a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="/breakpoint/posts/"> 所有文章 </a><a class="menu-item" href="/breakpoint/tags/"> 标签 </a><a class="menu-item" href="/breakpoint/categories/"> 分类 </a><a class="menu-item" href="https://github.com/COOL-BOYS-JACK-MA" title="GitHub" rel="noopener noreffer" target="_blank"><i class='fab fa-github fa-fw'></i>  </a><span class="menu-item delimiter"></span><span class="menu-item search" id="search-desktop">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-desktop">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-desktop">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </span><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                    <i class="fas fa-adjust fa-fw"></i>
                </a>
            </div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="/breakpoint/" title="断点的博客"><span class="header-title-pre"><i class='far fa-kiss-wink-heart fa-fw'></i></span><span id="id-2" class="typeit"></span></a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><div class="search-wrapper">
                    <div class="search mobile" id="search-mobile">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-mobile">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-mobile">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </div>
                    <a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile">
                        取消
                    </a>
                </div><a class="menu-item" href="/breakpoint/posts/" title="">所有文章</a><a class="menu-item" href="/breakpoint/tags/" title="">标签</a><a class="menu-item" href="/breakpoint/categories/" title="">分类</a><a class="menu-item" href="https://github.com/COOL-BOYS-JACK-MA" title="GitHub" rel="noopener noreffer" target="_blank"><i class='fab fa-github fa-fw'></i></a><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                <i class="fas fa-adjust fa-fw"></i>
            </a></div>
    </div>
</header>
<div class="search-dropdown desktop">
    <div id="search-dropdown-desktop"></div>
</div>
<div class="search-dropdown mobile">
    <div id="search-dropdown-mobile"></div>
</div>
<main class="main">
                <div class="container"><div class="toc" id="toc-auto">
            <h2 class="toc-title">目录</h2>
            <div class="toc-content" id="toc-content-auto"></div>
        </div><article class="page single"><h1 class="single-title animated flipInX">Redis安装及远程连接相关的问题(Linux--docker)</h1><div class="post-meta">
            <div class="post-meta-line"><span class="post-author"><a href="https://blog.csdn.net/qq_44643051" title="Author" target="_blank" rel="noopener noreffer author" class="author"><i class="fas fa-user-circle fa-fw"></i>BreakPoint2333</a></span>&nbsp;<span class="post-category">收录于 <a href="/breakpoint/categories/%E5%AE%9E%E6%88%98%E9%A1%B9%E7%9B%AE%E6%90%AD%E5%BB%BA/"><i class="far fa-folder fa-fw"></i>实战项目搭建</a></span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="2020-07-04">2020-07-04</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;约 751 字&nbsp;
                <i class="far fa-clock fa-fw"></i>&nbsp;预计阅读 2 分钟&nbsp;</div>
        </div><div class="details toc" id="toc-static"  kept="">
                <div class="details-summary toc-title">
                    <span>目录</span>
                    <span><i class="details-icon fas fa-angle-right"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents">
  <ul>
    <li><a href="#使用须知">使用须知</a></li>
    <li><a href="#安装步骤">安装步骤</a></li>
    <li><a href="#使用">使用</a>
      <ul>
        <li></li>
      </ul>
    </li>
    <li><a href="#退出">退出</a></li>
    <li><a href="#删除镜像">删除镜像</a></li>
  </ul>
</nav></div>
            </div><div class="content" id="content"><p>在你的服务器上用docker安装Redis及远程连接相关的问题</p>
<p>原文地址 <a href="https://www.runoob.com/docker/docker-install-redis.html">https://www.runoob.com/docker/docker-install-redis.html</a></p>
<p>shell，xftp下载链接 链接： <a href="https://pan.baidu.com/s/1E4pV_MsTxHK6tp3T0jvjjw">https://pan.baidu.com/s/1E4pV_MsTxHK6tp3T0jvjjw</a> 
提取码：9js2 
复制这段内容后打开百度网盘手机App，操作更方便哦</p>
<h2 id="使用须知">使用须知</h2>
<ol>
<li>运行环境在Linux环境下,非Windows</li>
<li>安装前务必卸载本机的redis,防止开机自启端口和docker冲突;
<ul>
<li>查找某个文件位置<code>find / -name redis</code></li>
</ul>
</li>
<li>掌握下列命令
<ol>
<li>查看相关进程运行命令 <code>ps aux | grep redis</code></li>
<li>杀死进程命令 <code>kill -9 processID</code></li>
<li>查看公网IP  <code>curl ifconfig.me</code></li>
</ol>
</li>
</ol>
<h2 id="安装步骤">安装步骤</h2>
<ol>
<li>取最新版的 Redis 镜像 <code>docker pull redis:latest</code></li>
<li>使用以下命令来查看是否已安装了 redis：
<code> docker images</code></li>
<li>安装完成后，我们可以使用以下命令来运行 redis 容器：<code> docker run -itd --name redis-test -p 6379:6379 redis</code>
<ul>
<li>查看正在运行的docker<code>docker ps</code> 查看曾经运行过容器 <code>docker ps -a</code></li>
<li>说明-p 6379:6379：映射容器服务的 6379 端口到宿主机的 6379 端口。外部可以直接通过宿主机ip:6379 访问到 Redis 的服务</li>
<li>补充一点,若再次运行容器时使用 <code>docker restart 镜像名</code>  原文地址 <a href="https://www.cnblogs.com/youxin/p/12993816.html">https://www.cnblogs.com/youxin/p/12993816.html</a></li>
<li>停止正在运行的容器（这里的34c7d71b8012是正在运行容器的编号） <code>docker stop 34c7d71b8012</code></li>
</ul>
</li>
</ol>
<h2 id="使用">使用</h2>
<p>本地连接Redis命令 <code>docker exec -ti redis-ruoyi redis-cli -h localhost -p 6379</code></p>
<ul>
<li>redis-ruoyi是正在运行的Redis容器名</li>
</ul>
<h4 id="远程连接连接参数">远程连接,连接参数</h4>
<ol>
<li>公网ip  <code>curl ifconfig.me</code></li>
<li>端口</li>
<li>账户,密码</li>
</ol>
<p>之后测试连接,连接完成</p>
<h4 id="设置密码">设置密码</h4>
<ol>
<li>连接后设置密码 <code>config set requirepass 123456</code></li>
<li>查看密码 <code>config get requirepass</code></li>
<li>连接后进行验证 <code>auth 123456</code></li>
</ol>
<h2 id="退出">退出</h2>
<ol>
<li>命令输入两次 <code>exit;</code>
<ul>
<li>第一次退出redis;第二次退出docker;</li>
</ul>
</li>
</ol>
<h2 id="删除镜像">删除镜像</h2>
<p>原文地址(感谢大佬的博客,写的很好) <a href="http://yaxin-cn.github.io/Docker/how-to-delete-a-docker-image.html">http://yaxin-cn.github.io/Docker/how-to-delete-a-docker-image.html</a></p>
<p>由于image被某个container引用（拿来运行），如果不将这个引用的container销毁（删除），那image肯定是不能被删除,所以</p>
<ol>
<li>需停止引用正在运行中的引用镜像容器(2eee2cd366a7是容器运行时的id) <code>docker stop 2eee2cd366a7</code></li>
<li>如果容器已经停止运行啦,直接删除容器 <code>docker rm 34c7d71b8012</code></li>
<li>最后删除镜像(ed9c93747fe1是镜像id) <code>docker rmi ed9c93747fe1</code></li>
</ol></div><div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>更新于 2020-07-04</span>
            </div>
            <div class="post-info-license"></div>
        </div>
        <div class="post-info-line">
            <div class="post-info-md"></div>
            <div class="post-info-share">
                <span><a href="javascript:void(0);" title="分享到 Twitter" data-sharer="twitter" data-url="https://breakpoint2333.gitee.io/breakpoint/posts/redis%E5%AE%89%E8%A3%85%E5%8F%8A%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5%E7%9B%B8%E5%85%B3%E7%9A%84%E9%97%AE%E9%A2%98/" data-title="Redis安装及远程连接相关的问题(Linux--docker)" data-hashtags="项目搭建,docker,linux"><i class="fab fa-twitter fa-fw"></i></a></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"><i class="fas fa-tags fa-fw"></i>&nbsp;<a href="/breakpoint/tags/%E9%A1%B9%E7%9B%AE%E6%90%AD%E5%BB%BA/">项目搭建</a>,&nbsp;<a href="/breakpoint/tags/docker/">docker</a>,&nbsp;<a href="/breakpoint/tags/linux/">linux</a></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">返回</a></span>&nbsp;|&nbsp;<span><a href="/breakpoint/">主页</a></span>
        </section>
    </div>

    <div class="post-nav"><a href="/breakpoint/posts/emoji-support/" class="prev" rel="prev" title="官方Emoji 支持"><i class="fas fa-angle-left fa-fw"></i>官方Emoji 支持</a>
            <a href="/breakpoint/posts/mysql-docker%E5%AE%89%E8%A3%85/" class="next" rel="next" title="MySQL安装-docker">MySQL安装-docker<i class="fas fa-angle-right fa-fw"></i></a></div>
</div>
</article></div>
            </main><footer class="footer">
        <div class="footer-container"><div class="footer-line">这里是断点的世界</div><div class="footer-line"><span class="author" itemprop="copyrightHolder">&nbsp;<a href="/breakpoint/" target="_blank">断点</a></span><span class="icp-splitter">&nbsp;|&nbsp;</span><br class="icp-br"/>
                    <span class="icp">豫ICP备20011333号</span></div>
        </div>
    </footer></div>

        <div id="fixed-buttons"><a href="#" id="back-to-top" class="fixed-button" title="回到顶部">
                <i class="fas fa-arrow-up fa-fw"></i>
            </a><a href="#" id="view-comments" class="fixed-button" title="查看评论">
                <i class="fas fa-comment fa-fw"></i>
            </a>
        </div><link rel="stylesheet" href="/breakpoint/lib/lightgallery/lightgallery.min.css"><script type="text/javascript" src="/breakpoint/lib/smooth-scroll/smooth-scroll.min.js"></script><script type="text/javascript" src="/breakpoint/lib/autocomplete/autocomplete.min.js"></script><script type="text/javascript" src="/breakpoint/lib/lunr/lunr.min.js"></script><script type="text/javascript" src="/breakpoint/lib/lunr/lunr.stemmer.support.min.js"></script><script type="text/javascript" src="/breakpoint/lib/lunr/lunr.zh.min.js"></script><script type="text/javascript" src="/breakpoint/lib/lazysizes/lazysizes.min.js"></script><script type="text/javascript" src="/breakpoint/lib/lightgallery/lightgallery.min.js"></script><script type="text/javascript" src="/breakpoint/lib/lightgallery/lg-thumbnail.min.js"></script><script type="text/javascript" src="/breakpoint/lib/lightgallery/lg-zoom.min.js"></script><script type="text/javascript" src="/breakpoint/lib/clipboard/clipboard.min.js"></script><script type="text/javascript" src="/breakpoint/lib/sharer/sharer.min.js"></script><script type="text/javascript" src="/breakpoint/lib/typeit/typeit.min.js"></script><script type="text/javascript">window.config={"code":{"copyTitle":"复制到剪贴板","maxShownLines":10},"comment":{},"data":{"id-1":"断点的世界","id-2":"断点的世界"},"lightGallery":{"actualSize":false,"exThumbImage":"data-thumbnail","hideBarsDelay":2000,"selector":".lightgallery","speed":400,"thumbContHeight":80,"thumbWidth":80,"thumbnail":true},"search":{"highlightTag":"em","lunrIndexURL":"/breakpoint/index.json","lunrLanguageCode":"zh","lunrSegmentitURL":"/breakpoint/lib/lunr/lunr.segmentit.js","maxResultLength":10,"noResultsFound":"没有找到结果","snippetLength":50,"type":"lunr"},"typeit":{"cursorChar":null,"cursorSpeed":null,"data":{"id-1":["id-1"],"id-2":["id-2"]},"duration":null,"speed":null}};</script><script type="text/javascript" src="/breakpoint/js/theme.min.js"></script></body>
</html>
